package com.moli.iov.his.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moli.iov.his.mapper.ReportSelledOnlineMapper;
import com.moli.iov.his.model.po.ReportSelledOnline;
import com.moli.iov.his.model.po.ReportTotalOnline;
import com.moli.iov.his.service.IReportSelledOnlineService;
import com.moli.iov.his.util.HisUtil;
import com.moli.iov.rest.RestResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 已售车辆上线统计 服务实现类
 * </p>
 *
 * @author sy
 * @since 2018-12-06
 */
@Service("reportSelledOnlineService")
public class ReportSelledOnlineServiceImpl extends ServiceImpl<ReportSelledOnlineMapper, ReportSelledOnline> implements IReportSelledOnlineService {

    @Autowired
    private ReportSelledOnlineMapper reportSelledOnlineMapper;

    @Override
    public RestResponse saveReportSelledOnline(ReportSelledOnline reportSelledOnline) {
        boolean save = save(reportSelledOnline);
        return save ? RestResponse.success() : RestResponse.failure("新增已售车辆统计失败！");
    }

    @Override
    public List<ReportSelledOnline> querySelledOnlineReport() throws Exception {

        List<ReportSelledOnline> reportSelledOnlines = reportSelledOnlineMapper.querySelledOnlineReport();
        List<ReportSelledOnline> ret = HisUtil.getSelledOnlineDateReport(reportSelledOnlines);
        return ret;

//        List<ReportSelledOnline> ret = reportSelledOnlineMapper.querySelledOnlineReport();
//        return ret;
    }

    @Override
    public List<ReportSelledOnline> querySelledOnlineReportByTime(Map map) throws Exception {
        return reportSelledOnlineMapper.querySelledOnlineReportByTime(map);
    }
}
